<?php 


class Panel extends CI_Controller {
    
    function __construct(){
        parent::__construct();
        $this->load->library('template');
        $this->load->model('m_panel');
    }
    
    function index(){
        $data['query'] = $this->m_panel->getAllDataLoket();
        $this->template->display_frontend('frontend/panel',$data);
    }
    
    function send(){
        $m_loket_id = $this->input->post('m_loket_id');
        $loket_kode = $this->input->post('loket_kode');
        $query = $this->m_panel->getMaxLoket($m_loket_id); 
        $pengunjung_nomor = $loket_kode.sprintf("%04d",$query->row('pengunjung_seq'));
        $data  = array(
            "pengunjung_seq"    => $query->row('pengunjung_seq'),
            "pengunjung_nomor"  => $pengunjung_nomor,
            "pengunjung_waktu"  => date("Y-m-d H:i:s"),
            "m_loket_id"        => $m_loket_id,
            "pengunjung_status" => 0
        );
        
        $this->m_panel->send($data);
        echo $pengunjung_nomor;
    }
}